Skip to content

feat(sandbox): support streaming single-file transfers - #4557

Open
liulingluan wants to merge 5 commits into
agentscope-ai:mainfrom
liulingluan:feat/sandbox-streaming-transfer
Open

liulingluan wants to merge 5 commits into
agentscope-ai:mainfrom
liulingluan:feat/sandbox-streaming-transfer

Conversation

@liulingluan

Copy link
Copy Markdown

AgentScope-Java Version

2.1.0-SNAPSHOT

Description

Related to #3781.

Single-file transfers currently require complete byte[] payloads, so memory grows with file size and concurrent downloads. Add stream-based upload/download APIs while preserving the existing byte-array and bulk APIs.

  • Add compatible defaults to SandboxFileTransfer and AbstractFilesystem, and forward streams through filesystem routing and per-call runtime bindings.
  • Implement native streaming for Local, Docker, E2B and Kubernetes. Preserve caller-owned streams, validate upload length, and report failures through the existing filesystem result types.
  • Resolve workspace-relative native downloads and root-directory paths correctly. Bound Kubernetes local-tunnel WebSocket writes to prevent large-upload heap exhaustion, preserving cancellation and transport ownership.
  • Add regression tests, update the example, and keep English/Chinese filesystem documentation aligned.

Validation

Rebased onto upstream main at 2644b0f97 before rerunning the full build and documentation checks.

  • Java 17: mvn -B -T1C -Ddocker.it=true clean verify — 114 modules successful; 14,141 tests reported, 218 conditionally skipped, zero failures/errors. The 13 changed test classes contain 176 tests, all executed successfully. Spotless checks passed.
  • Documentation: npm test (20 passed), npm run validate, and npm run broken-links passed.
  • After rebasing, real Docker Harness probes passed: three USER-scope calls checked sharing/isolation, and four concurrent SESSION calls each completed two 1 MiB round trips. All test containers were removed and pre-existing containers were preserved.
  • Earlier acceptance probes on the unchanged streaming implementation passed: Local, Docker, envd and Kubernetes 2,165,309,443-byte uploads/downloads with -Xmx64m, matching source/download/remote SHA-256; four concurrent contexts with 20 round trips each; Harness invocation, stream ownership, interruption, timeout and recovery checks passed.
  • Linux Docker clients/backends: 16 probe cases passed across native ARM64 and emulated AMD64, using the local ARM64 Docker Desktop daemon. Each architecture included four concurrent Harness calls with 20 round trips per call.
  • An existing Aliyun E2B-compatible instance passed 16 MiB transfers, four concurrent 8 MiB transfers, Harness routing and authentication/error checks. Its 32 MiB request-body limit was verified as an expected rejection.

Scope and limits

Workspace archive/snapshot streaming is outside this PR. Unsupported backends/paths retain the buffered compatibility fallback. Provider/gateway request limits and independent server-side buffering still apply; the official Kubernetes Python runtime buffers uploads. Official E2B-hosted sandbox creation/deletion, Windows, and a separate physical AMD64 Docker daemon were not exercised. The added automated tests use local fixtures and require no provider credentials.

Checklist

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test), with the conditional skips noted above
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (links and examples)
  • Code is ready for review

@mintlify

mintlify Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 1b43be5.

Approve preview

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant